# !/usr/bin/env python
# -*- coding:utf-8 -*-

import subprocess, os

def main():
    res = ['<!DOCTYPE RCC>\n<RCC version="1.0">\n  <qresource>']
    for sub_dir in('icons', 'qss'):
        if os.path.isdir(sub_dir):
            for afile in os.listdir(sub_dir):
                res.append('    <file alias="{0}/{1}">{0}/{1}</file>'.format(sub_dir, afile))
    res.append('  </qresource>\n</RCC>')
    f = open('resources.qrc', 'w')
    f.write('\n'.join(res))
    f.close()
    pipe = subprocess.Popen(r'pyrcc5 -o resources.py resources.qrc', stdout = subprocess.PIPE, stdin = subprocess.PIPE, stderr = subprocess.PIPE, creationflags=0x08)

if __name__ == '__main__':
    main()